import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    userInfo: {
      id: null,
      name: "",
      email: "",
    },
  },
  mutations: {
    setUser(state, data) {
      state.userInfo = { ...state.userInfo, ...data };
    },
  },
  actions: {
    setUserInfo({ commit }, data) {
      commit("setUser", data);
    },
  },
  getters: {
    getUserInfo: (state) => state.userInfo,
  },
});

export default store;
